package com.xyy.saas.payment.cores.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author wangzeqi
 */
@Getter
public enum AbchinaLoanOrderCheckResEnum {

    VERIFIED_PASS("0", "核验通过可下单"),
    CONTRACT_STATUS_INVALID("1", "客户合约状态非正常或不存在贷款"),
    INSUFFICIENT_BALANCE("2", "贷款可用余额不足"),
    INVALID_PAYMENT_ACCOUNT("3", "受托支付账号有误"),
    UNPAID_ORDER_EXISTS("4", "存在未支付订单"),
    ;

    private final String code;
    private final String description;

    AbchinaLoanOrderCheckResEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static AbchinaLoanOrderCheckResEnum fromCode(String code) {
        for (AbchinaLoanOrderCheckResEnum status : AbchinaLoanOrderCheckResEnum.values()) {
            if (Objects.equals(status.getCode(), code)) {
                return status;
            }
        }
        return null;
    }

}
